package com.koron.tool.frame;

import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyVetoException;

import javax.swing.AbstractAction;
import javax.swing.KeyStroke;

import com.koron.tool.MainFrame;

public class EnumAction extends AbstractAction {
	MainFrame frame;

	public EnumAction(MainFrame parent) {
		this.frame = parent;
		super.putValue(NAME, "枚举");
		putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK+InputEvent.ALT_MASK));
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		EnumFrame inf = EnumFrame.getInstance(frame);
		if (inf.getDesktopPane() == null) {
			frame.getDesktop().add(inf);
			try {
				inf.setSelected(true);
			} catch (PropertyVetoException e1) {
			}
		} else
			try {
				inf.setSelected(true);
			} catch (PropertyVetoException e1) {
				e1.printStackTrace();
			}
	}
}